/**   
 * @fileName XmlApplicationContext.java
 * @package com.sllx.frost.ioc.context
 * @copyright (c) 2014, sincerebravefight@gmail.com All Rights Reserved. 
 * @description XML应用上下文
 * @author sllx  
 * @date 2014-5-9 下午3:28:05
 * @modifiedBy sllx
 * @ModifiedDate 2014-5-9 下午3:28:05
   * Why & What is modified
 * @version V1.0
 */
package com.sllx.frost.ioc.context;

import java.util.Map;

import com.sllx.frost.ioc.ApplicationContext;
import com.sllx.frost.ioc.config.xml.Reader;
import com.sllx.frost.ioc.inject.XmlInjector;

/**
 * @className XmlApplicationContext
 * @description XML应用上下文
 * @author sllx
 * @date 2014-5-9 下午3:28:05
 * @modifiedBy sllx
 * @ModifiedDate 2014-5-9 下午3:28:05
 * Why & What is modified
 */
public class XmlApplicationContext implements ApplicationContext{
	
	/**
	 * 容器
	 */
	private Map<String, Object> beans;
	
	
	
	/**
	 * 初始化
	 * @param xmlPath
	 */
	private XmlApplicationContext(String xmlPath) {
		beans = XmlInjector.inject(Reader.loadXml(xmlPath));
	}
	
	
	
	/**
	 * 加载配置文件，生成上下文环境
	 * @param xmlPath
	 * @return
	 */
	public static XmlApplicationContext loadXml(String xmlPath) {
		return new XmlApplicationContext(xmlPath);
	}

	/* (non-Javadoc)
	 * @see com.sllx.frost.ioc.ApplicationContext#getBean(java.lang.String)
	 */
	public Object getBean(String beanId) {
		return beans.get(beanId);
	}
	
}
